import { defineStore } from "pinia";
import axios from "axios";
import { nanoid } from "nanoid";

export const useLoveTalkStore = defineStore('lovetalk', {
    state() {
        return {
            talkList: [
                { id: 'abdfag01', title: '今天你有一点怪，哪里怪？怪好看的！' },
                { id: 'abdfag02', title: '草莓、蓝莓、蔓越莓，今天想我了没？' },
                { id: 'abdfag03', title: '心里给你留了一块地，我的死心塌地~' },
            ]
        }
    },
    actions: {
        async getATalk() {
            let { data: { content: title } } = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json');
            let obj = { id: nanoid(), title };
            this.talkList.push(obj);
        }
    }
});